<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>numpy的使用 | Miki&#39;s blog</title>
  <meta name="keywords" content=" 机器学习 ">
  <meta name="description" content="numpy的使用 | Miki&#39;s blog">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description" content="keywords: author: Miki language: zh-CN timezone:">
<meta property="og:type" content="website">
<meta property="og:title" content="标签">
<meta property="og:url" content="http://mikiblog.online/tags/index.html">
<meta property="og:site_name" content="Miki&#39;s blog">
<meta property="og:description" content="keywords: author: Miki language: zh-CN timezone:">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-02-22T01:48:02.000Z">
<meta property="article:modified_time" content="2020-02-22T01:50:40.651Z">
<meta property="article:author" content="Miki Zhu">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/img/1.jpg">

<link href="/css/style.css?v=1.0.1" rel="stylesheet">

<link href="/css/hl_theme/atom-dark.css?v=1.0.1" rel="stylesheet">

<link href="//cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="/js/jquery.autocomplete.min.js?v=1.0.1" ></script>

<script src="//cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.bootcss.com/nprogress/0.2.0/nprogress.min.js"></script>



<script src="/js/iconfont.js?v=1.0.1" ></script>

<meta name="generator" content="Hexo 4.2.0"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="false">
  <input class="theme_blog_path" value="">
</div>

<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/" class="avatar_target">
    <img class="avatar" src="/img/头像.jpg" />
</a>
<div class="author">
    <span>Miki Zhu</span>
</div>

<div class="icon">
    
        
    
        
        <a title="email" href="mailto:747876457@qq.com" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-email"></use>
                </svg>
            
        </a>
        
    
        
        <a title="qq" href="http://wpa.qq.com/msgrd?v=3&uin=747876457&site=qq&menu=yes" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-qq"></use>
                </svg>
            
        </a>
        
    
</div>




<ul>
    <li><div class="all active">全部文章<small>(29)</small></div></li>
    
        
            
            <li><div data-rel="机器学习">机器学习<small>(7)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="机器学习实战">机器学习实战<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="项目实战">项目实战<small>(4)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="博客搭建">博客搭建<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="算法">算法<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="python教程">python教程<small>(1)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="学习网站推荐">学习网站推荐<small>(1)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="考研经验">考研经验<small>(1)</small></div>
                
            </li>
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
    
    
    
    
    </div>
    <div><a class="about  " target="_blank" href="/about">关于</a></div>
</div>
<input type="hidden" id="yelog_site_posts_number" value="29">
<input type="hidden" id="yelog_site_word_count" value="62.1k">
<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        友情链接
        <i class="back-title-list"></i>
    </div>
    <div class="friends-content">
        <ul>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <form onkeydown="if(event.keyCode === 13){return false;}">
        <input id="local-search-input" class="search" type="text" placeholder="Search..." />
        <i class="cross"></i>
        <span>
            <label for="tagswitch">Tags:</label>
            <input id="tagswitch" type="checkbox" style="display: none" />
            <i id="tagsWitchIcon"></i>
        </span>
    </form>
    <div class="tags-list">
    
    <li class="article-tag-list-item">
        <a class="color5">机器学习</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">算法</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">博客搭建</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">python</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">网站推荐</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">考研经验</a>
    </li>
    
    <div class="clearfix"></div>
</div>

    
    <nav id="title-list-nav">
        
        <a id="top" class="python教程 "
           href="/2020/04/03/python%E9%9D%A2%E8%AF%95%E9%A2%98/"
           data-tag="python"
           data-author="" >
            <span class="post-title" title="python面试题(不定期更新)">python面试题(不定期更新)</span>
            <span class="post-date" title="2020-04-03 21:14:43">2020/04/03</span>
        </a>
        
        <a id="top" class="考研经验 "
           href="/2020/02/20/%E8%80%83%E7%A0%94%E5%88%9D%E8%AF%95%E7%BB%8F%E9%AA%8C/"
           data-tag="考研经验"
           data-author="" >
            <span class="post-title" title="考研初试经验">考研初试经验</span>
            <span class="post-date" title="2020-02-20 19:33:48">2020/02/20</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/19/%E9%80%BB%E8%BE%91%E5%9B%9E%E5%BD%92%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="逻辑回归代码实现">逻辑回归代码实现</span>
            <span class="post-date" title="2020-04-19 21:09:25">2020/04/19</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/04/14/%E9%A9%AC%E5%B0%94%E5%8F%AF%E5%A4%AB%E9%93%BE/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="马尔可夫链">马尔可夫链</span>
            <span class="post-date" title="2020-04-14 19:09:29">2020/04/14</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/14/%E5%86%B3%E7%AD%96%E6%A0%91%E5%AE%9E%E6%88%98%E9%9A%90%E5%BD%A2%E7%9C%BC%E9%95%9C%E5%88%86%E7%B1%BB/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树实战隐形眼镜分类">决策树实战隐形眼镜分类</span>
            <span class="post-date" title="2020-04-14 10:49:40">2020/04/14</span>
        </a>
        
        <a  class="机器学习实战 "
           href="/2020/04/12/KNN%E5%AE%9E%E6%88%98%E4%B9%8B%E6%B5%B7%E4%BC%A6%E7%BA%A6%E4%BC%9A/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="KNN实战之海伦约会">KNN实战之海伦约会</span>
            <span class="post-date" title="2020-04-12 08:22:12">2020/04/12</span>
        </a>
        
        <a  class="博客搭建 "
           href="/2020/04/08/hexo-%E4%B8%BB%E9%A2%98%E6%B7%BB%E5%8A%A0%E8%AF%84%E8%AE%BA/"
           data-tag="博客搭建"
           data-author="" >
            <span class="post-title" title="hexo 主题添加评论">hexo 主题添加评论</span>
            <span class="post-date" title="2020-04-08 21:43:26">2020/04/08</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/30/%E6%98%8E%E5%A4%A9%E4%BC%9A%E4%B8%8B%E9%9B%A8%E5%90%97%EF%BC%9F/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="明天会下雨吗？">明天会下雨吗？</span>
            <span class="post-date" title="2020-03-30 11:25:31">2020/03/30</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/23/%E5%86%B3%E7%AD%96%E6%A0%91%E5%AE%9E%E7%8E%B0Titanic-%E9%87%8D%E8%A6%81/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树实现Titanic(重要)">决策树实现Titanic(重要)</span>
            <span class="post-date" title="2020-03-23 17:09:05">2020/03/23</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/21/Titanic-%E9%A1%B9%E7%9B%AE%E8%AF%A6%E8%A7%A3/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="Titanic 项目详解">Titanic 项目详解</span>
            <span class="post-date" title="2020-03-21 14:07:20">2020/03/21</span>
        </a>
        
        <a  class="项目实战 "
           href="/2020/03/19/kaggle%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="kaggle项目实战，Titanic analysis">kaggle项目实战，Titanic analysis</span>
            <span class="post-date" title="2020-03-19 10:08:13">2020/03/19</span>
        </a>
        
        <a  class=""
           href="/2020/03/17/Pytorch-%E6%90%AD%E5%BB%BA%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Pytorch 搭建神经网络">Pytorch 搭建神经网络</span>
            <span class="post-date" title="2020-03-17 14:56:16">2020/03/17</span>
        </a>
        
        <a  class=""
           href="/2020/03/16/CNN%E5%8E%9F%E7%90%86/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="CNN">CNN</span>
            <span class="post-date" title="2020-03-16 09:11:00">2020/03/16</span>
        </a>
        
        <a  class=""
           href="/2020/03/14/%E9%9A%8F%E6%9C%BA%E6%A3%AE%E6%9E%97%E5%92%8Ck%E5%9D%87%E5%80%BC/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="random forest and k means">random forest and k means</span>
            <span class="post-date" title="2020-03-14 16:29:22">2020/03/14</span>
        </a>
        
        <a  class=""
           href="/2020/03/13/%E6%94%AF%E6%8C%81%E5%90%91%E9%87%8F%E6%9C%BA%E7%AE%97%E6%B3%95/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="支持向量机">支持向量机</span>
            <span class="post-date" title="2020-03-13 20:53:20">2020/03/13</span>
        </a>
        
        <a  class=""
           href="/2020/03/11/Matplotlab/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="Matplotlab">Matplotlab</span>
            <span class="post-date" title="2020-03-11 10:13:20">2020/03/11</span>
        </a>
        
        <a  class=""
           href="/2020/03/10/pandas/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="pandas">pandas</span>
            <span class="post-date" title="2020-03-10 09:20:27">2020/03/10</span>
        </a>
        
        <a  class=""
           href="/2020/03/09/logical-regression/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="logical regression">logical regression</span>
            <span class="post-date" title="2020-03-09 20:30:33">2020/03/09</span>
        </a>
        
        <a  class="学习网站推荐 "
           href="/2020/03/08/%E5%AD%A6%E4%B9%A0%E7%BD%91%E7%AB%99%E6%88%96%E5%B7%A5%E5%85%B7%E6%8E%A8%E8%8D%90/"
           data-tag="网站推荐"
           data-author="" >
            <span class="post-title" title="学习网站或工具推荐">学习网站或工具推荐</span>
            <span class="post-date" title="2020-03-08 20:44:55">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/08/%E8%B4%9D%E5%8F%B6%E6%96%AF%E5%88%86%E6%9E%90/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="贝叶斯分析">贝叶斯分析</span>
            <span class="post-date" title="2020-03-08 20:11:15">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/08/numpy/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="numpy的使用">numpy的使用</span>
            <span class="post-date" title="2020-03-08 19:15:54">2020/03/08</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/07/%E5%86%B3%E7%AD%96%E6%A0%91/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="决策树">决策树</span>
            <span class="post-date" title="2020-03-07 19:27:38">2020/03/07</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/06/K-%E8%BF%91%E9%82%BB%E7%AE%97%E6%B3%95/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="K-近邻算法">K-近邻算法</span>
            <span class="post-date" title="2020-03-06 20:18:19">2020/03/06</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/05/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="排序算法">排序算法</span>
            <span class="post-date" title="2020-03-05 19:41:32">2020/03/05</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/04/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E6%97%B6%E9%97%B4%E5%A4%8D%E6%9D%82%E5%BA%A6/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="数据结构与时间复杂度">数据结构与时间复杂度</span>
            <span class="post-date" title="2020-03-04 21:00:32">2020/03/04</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/04/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="机器学习数学基础">机器学习数学基础</span>
            <span class="post-date" title="2020-03-04 16:48:34">2020/03/04</span>
        </a>
        
        <a  class="算法 "
           href="/2020/03/03/leetcode%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/"
           data-tag="算法"
           data-author="" >
            <span class="post-title" title="哈希图 and 移动窗口">哈希图 and 移动窗口</span>
            <span class="post-date" title="2020-03-03 18:49:52">2020/03/03</span>
        </a>
        
        <a  class="机器学习 "
           href="/2020/03/01/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%9F%BA%E6%9C%AC%E6%9C%AF%E8%AF%AD/"
           data-tag="机器学习"
           data-author="" >
            <span class="post-title" title="1 零基础学机器学习">1 零基础学机器学习</span>
            <span class="post-date" title="2020-03-01 20:23:40">2020/03/01</span>
        </a>
        
        <a  class="博客搭建 "
           href="/2020/02/20/Windows%E7%B3%BB%E7%BB%9F%E4%B8%8B%E7%94%A8hexo%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/"
           data-tag="博客搭建"
           data-author="" >
            <span class="post-title" title="Windows系统下用hexo搭建个人博客">Windows系统下用hexo搭建个人博客</span>
            <span class="post-date" title="2020-02-20 13:15:25">2020/02/20</span>
        </a>
        
    </nav>
</div>
    </div>
    <div class="hide-list">
        <div class="semicircle">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div class="post">
    <div class="pjax">
        <article id="post-numpy" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">numpy的使用</h1>
    
    <div class="article-meta">
        
        
        
        <span class="book">
            
                <a  data-rel="机器学习">机器学习</a>
            
        </span>
        
        
        <span class="tag">
            
            <a class="color5">机器学习</a>
            
        </span>
        
    </div>
    <div class="article-meta">
        
        创建时间:<time class="date" title='更新时间: 2020-03-09 20:26:41'>2020-03-08 19:15</time>
        
    </div>
    <div class="article-meta">
        
        <span>字数:2.4k</span>
        
        
        <span id="busuanzi_container_page_pv">
            阅读:<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
        <span class="top-comment" title="跳转至评论区">
            <a href="#comments">
                评论:<span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </a>
        </span>
        
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#numpy的用法"><span class="toc-text"> numpy的用法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#使用notepad打开csv文件"><span class="toc-text"> 使用notepad打开csv文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#python中的矩阵"><span class="toc-text"> python中的矩阵</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#获得矩阵的属性"><span class="toc-text"> 获得矩阵的属性</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#dtype用法"><span class="toc-text"> dtype用法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#zeros创建0矩阵"><span class="toc-text"> zeros，创建0矩阵</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#ones创建1矩阵"><span class="toc-text"> ones，创建1矩阵</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#arange创建与range类似的矩阵"><span class="toc-text"> arange,创建与range类似的矩阵</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#linspace生成步长序列"><span class="toc-text"> linspace，生成步长序列</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的四则运算"><span class="toc-text"> 矩阵的四则运算</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的正弦余弦运算"><span class="toc-text"> 矩阵的正弦余弦运算</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#逻辑运算"><span class="toc-text"> 逻辑运算</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵乘法和普通乘法运算"><span class="toc-text"> 矩阵乘法和普通乘法运算</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#生成随机矩阵"><span class="toc-text"> 生成随机矩阵</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#求矩阵的最大最小或者求和"><span class="toc-text"> 求矩阵的最大最小，或者求和</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#找到最大值最小值的坐标argmin"><span class="toc-text"> 找到最大值最小值的坐标argmin</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#计算矩阵的平均值mean中位数median"><span class="toc-text"> 计算矩阵的平均值mean，中位数median</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#累加所有元素cumsum"><span class="toc-text"> 累加所有元素cumsum</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#累差diff两数之间的差值"><span class="toc-text"> 累差diff,两数之间的差值</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#输出所有非0的坐标nonzero"><span class="toc-text"> 输出所有非0的坐标nonzero</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的转置transpose"><span class="toc-text"> 矩阵的转置transpose</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的逆i"><span class="toc-text"> 矩阵的逆.I</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#单位矩阵eye"><span class="toc-text"> 单位矩阵eye</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#对角矩阵diag"><span class="toc-text"> 对角矩阵diag</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#clip让大于或小于某个值的值统一"><span class="toc-text"> clip让大于或小于某个值的值统一</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的索引"><span class="toc-text"> 矩阵的索引</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#打印某一行或某一列的所有元素"><span class="toc-text"> 打印某一行或某一列的所有元素</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#for迭代矩阵每一行或每一列"><span class="toc-text"> for迭代矩阵每一行或每一列</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#for遍历矩阵每一个元素flatten"><span class="toc-text"> for遍历矩阵每一个元素flatten()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#多个矩阵的合并vstackhstack"><span class="toc-text"> 多个矩阵的合并vstack，hstack</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#上下合并vstack"><span class="toc-text"> 上下合并vstack</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#左右合并"><span class="toc-text"> 左右合并</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#numpy中mat和array的区别重点"><span class="toc-text"> numpy中mat和array的区别(重点)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#newaxis添加新的维度"><span class="toc-text"> newaxis添加新的维度</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#多个矩阵的合并concatenate"><span class="toc-text"> 多个矩阵的合并concatenate</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的分割"><span class="toc-text"> 矩阵的分割</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#均匀分割splitmatrixnumaxis"><span class="toc-text"> 均匀分割split(matrix,num,axis&#x3D;)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#不均匀分割arry_splitmatrixnumaxis"><span class="toc-text"> 不均匀分割arry_split(matrix,num,axis&#x3D;)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#对行vsplitmatrixnum对列hspilitmatrixnum分割"><span class="toc-text"> 对行vsplit(matrix,num)，对列hspilit(matrix,num)分割</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#矩阵的复制深复制浅复制"><span class="toc-text"> 矩阵的复制(深复制，浅复制)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#浅复制"><span class="toc-text"> 浅复制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#深复制copy"><span class="toc-text"> 深复制copy</span></a></li></ol></li></ol></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-3 i,
    .toc-level-3 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="numpy的用法"><a class="markdownIt-Anchor" href="#numpy的用法"></a> numpy的用法</h1>
<h2 id="使用notepad打开csv文件"><a class="markdownIt-Anchor" href="#使用notepad打开csv文件"></a> 使用notepad打开csv文件</h2>
<p>csv文件在电脑中默认是用excel打开的，最好使用记事本打开，因为用excel打开，会改变里面的数据，excel默认会用科学记数法表示一些很大的数。</p>
<ul>
<li><strong>注意numpy中对矩阵的各种运算都可以通过axis来指定是对行还是列运算，例如算mean等</strong></li>
</ul>
<h2 id="python中的矩阵"><a class="markdownIt-Anchor" href="#python中的矩阵"></a> python中的矩阵</h2>
<pre class="highlight"><code class="">matrix = [
    [1,2,3],
    [2,5,6]
]
print(matrix[1][2])
'''
answer = 6
可以看出123为第一行
'''
</code></pre>
<p>但这样实际上还是列表，用array创建矩阵，没有逗号隔开的</p>
<pre class="highlight"><code class="">array = np.array([
    [1,2,3],
    [4,5,6],
])
print(array)
'''
输出：
[[1 2 3]
 [4 5 6]]
'''
</code></pre>
<h3 id="获得矩阵的属性"><a class="markdownIt-Anchor" href="#获得矩阵的属性"></a> 获得矩阵的属性</h3>
<pre class="highlight"><code class=""># 把np的array类实例化
array = np.array([
    [1,2,3],
    [4,5,6],
    [0,0,0],
])
# 获得array的属性
print('number of dim:', array.ndim)
print('shape:', array.shape)
print('size:', array.size)

'''
输出：
#因为矩阵肯定是二维的，向量是一维的
number of dim: 2
shape: (3, 3)
size: 9
'''
</code></pre>
<h2 id="dtype用法"><a class="markdownIt-Anchor" href="#dtype用法"></a> dtype用法</h2>
<pre class="highlight"><code class="">array = np.array([
    [1.2,2,3],
    [4,5,6],
    [0,0,0],
], dtype=np.int)#一定要是np.int

print(array)
</code></pre>
<pre class="highlight"><code class="">[[1 2 3]
 [4 5 6]
 [0 0 0]]
</code></pre>
<p>如果定义是int类型，则矩阵的所有元素都是整数类型</p>
<pre class="highlight"><code class="">array = np.array([
    [1.2, 2, 3],
    [4, 5, 6],
    [0, 0, 0],
], dtype=np.float32)

print(array)
</code></pre>
<ul>
<li>位数越小，则需要的内存越小</li>
</ul>
<h2 id="zeros创建0矩阵"><a class="markdownIt-Anchor" href="#zeros创建0矩阵"></a> zeros，创建0矩阵</h2>
<pre class="highlight"><code class="">print(np.zeros((3, 4)))
</code></pre>
<pre class="highlight"><code class="">[[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]

</code></pre>
<ul>
<li>注意要用zeros，因为很多个0，<strong>同时函数里面还要用元组</strong></li>
</ul>
<h2 id="ones创建1矩阵"><a class="markdownIt-Anchor" href="#ones创建1矩阵"></a> ones，创建1矩阵</h2>
<pre class="highlight"><code class="">print(np.ones((3, 4), dtype=np.int))
</code></pre>
<pre class="highlight"><code class="">[[1 1 1 1]
 [1 1 1 1]
 [1 1 1 1]]
</code></pre>
<h2 id="arange创建与range类似的矩阵"><a class="markdownIt-Anchor" href="#arange创建与range类似的矩阵"></a> arange,创建与range类似的矩阵</h2>
<p><code>print(np.arange(0, 10, 2))</code>和python中的range是类似的</p>
<p>[0 2 4 6 8]</p>
<ul>
<li>
<p>arange中的reshape</p>
</li>
<li>
<p><code>print(np.arange(0, 12, 2).reshape((2, 3)))</code></p>
<pre class="highlight"><code class="">[[ 0  2  4]
 [ 6  8 10]]
</code></pre>
</li>
<li>
<p>要注意0-12步长为2，里面是有6个元素的，所以2x3也必须是6</p>
</li>
</ul>
<h2 id="linspace生成步长序列"><a class="markdownIt-Anchor" href="#linspace生成步长序列"></a> linspace，生成步长序列</h2>
<pre class="highlight"><code class="">print(np.linspace(0, 5, 10).reshape((2, 5)))
</code></pre>
<pre class="highlight"><code class="">[[0.         0.55555556 1.11111111 1.66666667 2.22222222]
 [2.77777778 3.33333333 3.88888889 4.44444444 5.        ]]
</code></pre>
<p>从0到5，生成10个元素，逐渐增大</p>
<h2 id="矩阵的四则运算"><a class="markdownIt-Anchor" href="#矩阵的四则运算"></a> 矩阵的四则运算</h2>
<pre class="highlight"><code class="">a = np.arange(4)
b = np.zeros(4)
#加减乘除
print(a + b)
print('------------')
print(a ** 2)
</code></pre>
<pre class="highlight"><code class="">[0. 1. 2. 3.]
------------
[0 1 4 9]
</code></pre>
<h2 id="矩阵的正弦余弦运算"><a class="markdownIt-Anchor" href="#矩阵的正弦余弦运算"></a> 矩阵的正弦余弦运算</h2>
<pre class="highlight"><code class="">a = np.arange(4)
b = np.zeros(4)
#正弦余弦运算
print(np.cos(b))
</code></pre>
<pre class="highlight"><code class="">[1. 1. 1. 1.]
</code></pre>
<p>对每个元素求余弦</p>
<h2 id="逻辑运算"><a class="markdownIt-Anchor" href="#逻辑运算"></a> 逻辑运算</h2>
<pre class="highlight"><code class="">a = np.arange(4)
b = np.zeros(4)
#逻辑运算
print(a != 0)
</code></pre>
<pre class="highlight"><code class="">[False  True  True  True]
</code></pre>
<p>对每个元素进行逻辑运算，同时还有&gt;, &lt;, ==</p>
<h2 id="矩阵乘法和普通乘法运算"><a class="markdownIt-Anchor" href="#矩阵乘法和普通乘法运算"></a> 矩阵乘法和普通乘法运算</h2>
<pre class="highlight"><code class="">a = np.array([
    [1,2],
    [4,5]
])
b = np.array([
    [0,1],
    [0,1]
])
print(a*b)
print(np.dot(a, b))
</code></pre>
<pre class="highlight"><code class="">第一个是每个元素对应相乘
第二个是矩阵乘法
</code></pre>
<p><strong>两个向量相乘</strong></p>
<pre class="highlight"><code class="">a = np.arange(4).reshape((4, 1))
b = np.arange(4).reshape((1, 4))
print(np.dot(b, a))
print(np.dot(a, b))
print(b.dot(a))#两种表达形式，这种也行
</code></pre>
<pre class="highlight"><code class="">[[14]]
[[0 0 0 0]
 [0 1 2 3]
 [0 2 4 6]
 [0 3 6 9]]
</code></pre>
<h2 id="生成随机矩阵"><a class="markdownIt-Anchor" href="#生成随机矩阵"></a> 生成随机矩阵</h2>
<pre class="highlight"><code class="">a = np.random.random(2)#生成一维矩阵
b = np.random.random((2,3))#生成二维矩阵
</code></pre>
<pre class="highlight"><code class="">[0.66455362 0.09184438]
[[0.8223943  0.53069539 0.20177849]
 [0.45198285 0.64385535 0.48249845]]
</code></pre>
<h2 id="求矩阵的最大最小或者求和"><a class="markdownIt-Anchor" href="#求矩阵的最大最小或者求和"></a> 求矩阵的最大最小，或者求和</h2>
<pre class="highlight"><code class="">a = np.random.random(2)#生成一维矩阵
b = np.random.random((2,3))#生成二维矩阵
print(np.max(a))
print(a.max())
print(np.min(b))
print(np.sum(a))
print(a.sum())
</code></pre>
<pre class="highlight"><code class="">0.8347105081382513
0.13517322901399886
1.5080307306652418
1.5080307306652418
</code></pre>
<pre class="highlight"><code class="">b = np.random.random((2,3))#生成二维矩阵
print(b)
print(b.min(axis=1))
print(b.min(axis=0))
</code></pre>
<pre class="highlight"><code class="">[[0.7780649  0.97145716 0.27643172]
 [0.06018098 0.29907257 0.83860847]]
[0.27643172 0.06018098]
[0.06018098 0.29907257 0.27643172]
</code></pre>
<ul>
<li>
<p>当axis=0时，表示在每一列中找到最大值</p>
</li>
<li>
<p>当axis=1时，表示在每一行中找到最大值</p>
</li>
</ul>
<h2 id="找到最大值最小值的坐标argmin"><a class="markdownIt-Anchor" href="#找到最大值最小值的坐标argmin"></a> 找到最大值最小值的坐标argmin</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.argmax(a))
print(np.argmin(a))
b = np.random.random((2,3))
print('---------------')
print(b)
print(np.argmin(b))
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
5
0
---------------
[[0.26097962 0.65723894 0.01457888]
 [0.32926792 0.0782571  0.66194859]]
2
</code></pre>
<ul>
<li>还记得matlab吧，其实和他是差不多的，从左0开始不断往右数</li>
<li><strong>agrement表示的是自变量的意思</strong></li>
</ul>
<h2 id="计算矩阵的平均值mean中位数median"><a class="markdownIt-Anchor" href="#计算矩阵的平均值mean中位数median"></a> 计算矩阵的平均值mean，中位数median</h2>
<pre class="highlight"><code class="">print(a.mean())
print(np.mean(a))
print(np.median(a))
</code></pre>
<pre class="highlight"><code class="">2.5
2.5
2.5
</code></pre>
<h2 id="累加所有元素cumsum"><a class="markdownIt-Anchor" href="#累加所有元素cumsum"></a> 累加所有元素cumsum</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.cumsum(a))
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
[ 0  1  3  6 10 15]
</code></pre>
<h2 id="累差diff两数之间的差值"><a class="markdownIt-Anchor" href="#累差diff两数之间的差值"></a> 累差diff,两数之间的差值</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.diff(a))
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
[[1 1]
 [1 1]]
</code></pre>
<h2 id="输出所有非0的坐标nonzero"><a class="markdownIt-Anchor" href="#输出所有非0的坐标nonzero"></a> 输出所有非0的坐标nonzero</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.nonzero(a))
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
(array([0, 0, 1, 1, 1], dtype=int64), array([1, 2, 0, 1, 2], dtype=int64))
</code></pre>
<p>左边表示行，右边表示列，如第0行1列是非0的</p>
<h2 id="矩阵的转置transpose"><a class="markdownIt-Anchor" href="#矩阵的转置transpose"></a> 矩阵的转置transpose</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.transpose(a))
print(a.T)#两种表示方式
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
[[0 3]
 [1 4]
 [2 5]]
[[0 3]
 [1 4]
 [2 5]]
</code></pre>
<h2 id="矩阵的逆i"><a class="markdownIt-Anchor" href="#矩阵的逆i"></a> 矩阵的逆.I</h2>
<h2 id="单位矩阵eye"><a class="markdownIt-Anchor" href="#单位矩阵eye"></a> 单位矩阵eye</h2>
<pre class="highlight"><code class="">data6 = np.mat(np.eye(2,2,dtype=int))
print(data6)

[[1 0]
 [0 1]]
</code></pre>
<h2 id="对角矩阵diag"><a class="markdownIt-Anchor" href="#对角矩阵diag"></a> 对角矩阵diag</h2>
<pre class="highlight"><code class="">a1 = [1,2,3]
a2 = np.mat(np.diag(a1))
print(a2)
'''
[[1 0 0]
 [0 2 0]
 [0 0 3]]
'''
</code></pre>
<h2 id="clip让大于或小于某个值的值统一"><a class="markdownIt-Anchor" href="#clip让大于或小于某个值的值统一"></a> clip让大于或小于某个值的值统一</h2>
<p><strong>语法np.clip(matrix, min, max)</strong></p>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(np.clip(a,1,4))
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
[[1 1 2]
 [3 4 4]]
</code></pre>
<p>我们可以看到介于max和min之间的数值保留了</p>
<h2 id="矩阵的索引"><a class="markdownIt-Anchor" href="#矩阵的索引"></a> 矩阵的索引</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(a[0][2])#打印第0行第2个元素
print(a[0, 2])
print(a[1])#打印第1行
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
2
[3 4 5]
</code></pre>
<ul>
<li>都是从0行0列开始的</li>
</ul>
<h3 id="打印某一行或某一列的所有元素"><a class="markdownIt-Anchor" href="#打印某一行或某一列的所有元素"></a> 打印某一行或某一列的所有元素</h3>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a)
print(a[:,0])
print(a[1,:])
</code></pre>
<pre class="highlight"><code class="">[[0 1 2]
 [3 4 5]]
[0 3]
[3 4 5]
</code></pre>
<ul>
<li><code>理解了可以这样表达就很容易记了print(a[0, 2])</code></li>
</ul>
<blockquote>
<p>a[: , 1]表示第1列的所有元素，就像列表一样可以切片</p>
</blockquote>
<pre class="highlight"><code class="">print(a[1,:][1:2])
</code></pre>
<p><code>[4]</code></p>
<ul>
<li>注意这个不是列表类型，而是矩阵类型，但依旧可以进行切片操作</li>
</ul>
<h2 id="for迭代矩阵每一行或每一列"><a class="markdownIt-Anchor" href="#for迭代矩阵每一行或每一列"></a> for迭代矩阵每一行或每一列</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
for each in a:
    print(each)
print('---------')
for each in a.T:
    print(each)
</code></pre>
<pre class="highlight"><code class="">[0 1 2]
[3 4 5]
---------
[0 3]
[1 4]
[2 5]
</code></pre>
<ul>
<li>直接for循环是遍历每一行，转置下就是遍历每一列了</li>
</ul>
<h2 id="for遍历矩阵每一个元素flatten"><a class="markdownIt-Anchor" href="#for遍历矩阵每一个元素flatten"></a> for遍历矩阵每一个元素flatten()</h2>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
for each in a.flatten():
    print(each)
</code></pre>
<pre class="highlight"><code class="">0
1
2
3
4
5
</code></pre>
<pre class="highlight"><code class="">a = np.arange(0,6).reshape((2,3))
print(a.flatten())#flatten就是转化成一维的
for each in a.flat:#flat这里是一个迭代器，可以和yeilt和next使用
    print(each)
</code></pre>
<pre class="highlight"><code class="">[0 1 2 3 4 5]
0
1
2
3
4
5
</code></pre>
<h2 id="多个矩阵的合并vstackhstack"><a class="markdownIt-Anchor" href="#多个矩阵的合并vstackhstack"></a> 多个矩阵的合并vstack，hstack</h2>
<h3 id="上下合并vstack"><a class="markdownIt-Anchor" href="#上下合并vstack"></a> 上下合并vstack</h3>
<ul>
<li>vstack表示vertical stack，上下堆积起来的意思</li>
<li><strong>注意vstack(())里面是元组</strong>,上下合并</li>
</ul>
<pre class="highlight"><code class="">a = np.array([1,2,3])
b = np.array([4,5,6])
print(np.vstack((a,b)))
</code></pre>
<pre class="highlight"><code class="">[[1 2 3]
 [4 5 6]]
</code></pre>
<h3 id="左右合并"><a class="markdownIt-Anchor" href="#左右合并"></a> 左右合并</h3>
<ul>
<li>hstack，horizontal stack</li>
</ul>
<pre class="highlight"><code class="">a = np.array([
    [1],
    [2],
    [3],
])
b = np.array([
    [2],
    [3],
    [4],
])
print(np.hstack((a,b)))
</code></pre>
<pre class="highlight"><code class="">[[1 2]
 [2 3]
 [3 4]]

</code></pre>
<h2 id="numpy中mat和array的区别重点"><a class="markdownIt-Anchor" href="#numpy中mat和array的区别重点"></a> numpy中mat和array的区别(重点)</h2>
<ul>
<li><strong>mat函数可以将其他类型的数据转换成矩阵类型，和matlab中的矩阵形式是一样的</strong></li>
</ul>
<pre class="highlight"><code class="">a = np.mat(np.ones((3,4)))
print(type(a))
print(type(np.zeros((3,4))))

&lt;class 'numpy.matrix'&gt;
&lt;class 'numpy.ndarray'&gt;#ndarray指的是存放同一数据类型的对象
</code></pre>
<ul>
<li>mat矩阵赋值</li>
</ul>
<pre class="highlight"><code class="">a = np.mat([1,2,3],dtype=float)
a[0] = 1.2
print(a)

[[1.2 1.2 1.2]]		#会发现整个输出都变成了1.2，而转变成array却不会
</code></pre>
<ul>
<li>mat生成矩阵有两种形式,而array只有一种形式</li>
</ul>
<pre class="highlight"><code class="">print(np.mat('1 2;3 4'))
print(np.mat([[1,2],[3,4]]))
</code></pre>
<pre class="highlight"><code class="">[[1 2]
 [3 4]]
[[1 2]
 [3 4]]
</code></pre>
<ul>
<li>
<p>(1) mat()函数中矩阵的乘积可以使用（星号） *  或 .dot()函数，其结果相同。而矩阵对应位置元素相乘需调用numpy.multiply()函数。</p>
<p>(2) array()函数中矩阵的乘积只能使用 .dot()函数。而星号乘 （*）则表示矩阵对应位置元素相乘，与numpy.multiply()函数结果相同。</p>
</li>
<li>
<p><a href="https://www.jb51.net/article/156109.htm%EF%BC%8C%E8%AF%A6%E7%BB%86%E5%8F%AF%E4%BB%A5%E7%9C%8B%E8%BF%99%E4%B8%AA" target="_blank" rel="noopener">https://www.jb51.net/article/156109.htm，详细可以看这个</a></p>
</li>
<li>
<p>array如果生成一个行向量，转置后是不会得到一个列向量的，只有mat才会生成一个列向量</p>
</li>
</ul>
<h2 id="newaxis添加新的维度"><a class="markdownIt-Anchor" href="#newaxis添加新的维度"></a> newaxis添加新的维度</h2>
<pre class="highlight"><code class="">a = np.array([1,1,1])[:,np.newaxis]#这里只有一个括号[]
print(a)
</code></pre>
<pre class="highlight"><code class="">[[1]
 [1]
 [1]]
(3, 1)
</code></pre>
<ul>
<li>相当于给每一个列添加新的维度</li>
<li><strong>注意，在调试的过程中，我想</strong></li>
</ul>
<pre class="highlight"><code class="">a = np.array([[1,1,1]])[:,np.newaxis],加了双[]，这样会失败，最后是变成了三个维度的张量
</code></pre>
<h2 id="多个矩阵的合并concatenate"><a class="markdownIt-Anchor" href="#多个矩阵的合并concatenate"></a> 多个矩阵的合并concatenate</h2>
<ul>
<li>axis = 0， 相当于上下维度合并，相当于vstack</li>
<li>axis = 0，左右两个维度合并，相当于hstack</li>
</ul>
<h2 id="矩阵的分割"><a class="markdownIt-Anchor" href="#矩阵的分割"></a> 矩阵的分割</h2>
<h3 id="均匀分割splitmatrixnumaxis"><a class="markdownIt-Anchor" href="#均匀分割splitmatrixnumaxis"></a> 均匀分割split(matrix,num,axis=)</h3>
<pre class="highlight"><code class="">a = np.mat(np.ones((3,4)))
b = np.split(a,2,axis=1)	#axis=1表示对列进行操作1看起来就是一列
print(b[0])
print(b[1])

[[1. 1.]
[1. 1.]
[1. 1.]]
[[1. 1.]
[1. 1.]
[1. 1.]]
</code></pre>
<h3 id="不均匀分割arry_splitmatrixnumaxis"><a class="markdownIt-Anchor" href="#不均匀分割arry_splitmatrixnumaxis"></a> 不均匀分割arry_split(matrix,num,axis=)</h3>
<pre class="highlight"><code class="">a = np.mat(np.ones((3,4)))
b = np.array_split(a,3,axis=1)
print(b[0])
print(b[1])
</code></pre>
<h3 id="对行vsplitmatrixnum对列hspilitmatrixnum分割"><a class="markdownIt-Anchor" href="#对行vsplitmatrixnum对列hspilitmatrixnum分割"></a> 对行vsplit(matrix,num)，对列hspilit(matrix,num)分割</h3>
<pre class="highlight"><code class="">a = np.mat(np.ones((3,4)))
print(np.vsplit(a, 3))#对行进行分割
print(np.hsplit(a, 2))#对列进行分割
</code></pre>
<pre class="highlight"><code class="">[matrix([[1., 1., 1., 1.]]), matrix([[1., 1., 1., 1.]]), matrix([[1., 1., 1., 1.]])]
[matrix([[1., 1.],
        [1., 1.],
        [1., 1.]]), matrix([[1., 1.],
        [1., 1.],
        [1., 1.]])]
</code></pre>
<h2 id="矩阵的复制深复制浅复制"><a class="markdownIt-Anchor" href="#矩阵的复制深复制浅复制"></a> 矩阵的复制(深复制，浅复制)</h2>
<h3 id="浅复制"><a class="markdownIt-Anchor" href="#浅复制"></a> 浅复制</h3>
<pre class="highlight"><code class="">b = np.array([0,1,2],dtype=float)
c = b
b[0] = 0.3
print(b)
print(c)

[0.3 1.  2. ]
[0.3 1.  2. ]
</code></pre>
<h3 id="深复制copy"><a class="markdownIt-Anchor" href="#深复制copy"></a> 深复制copy</h3>
<pre class="highlight"><code class="">b = a.copy()
</code></pre>

      
       
    </div>
</article>



<div class="article_copyright">
    <p><span class="copy-title">文章标题:</span>numpy的使用</p>
    <p><span class="copy-title">文章字数:</span><span class="post-count">2.4k</span></p>
    <p><span class="copy-title">本文作者:</span><a  title="Miki Zhu">Miki Zhu</a></p>
    <p><span class="copy-title">发布时间:</span>2020-03-08, 19:15:54</p>
    <p><span class="copy-title">最后更新:</span>2020-03-09, 20:26:41</p>
    <span class="copy-title">原始链接:</span><a class="post-url" href="/2020/03/08/numpy/" title="numpy的使用">http://mikiblog.online/2020/03/08/numpy/</a>
    <p>
        <span class="copy-title">版权声明:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
    </p>
</div>



    <div id="vcomment" class="comment"></div> 
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<script src="https://cdnjs.loli.net/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
    var notify = 'false' == true ? true : false;
    var verify = 'false' == true ? true : false;
    new Valine({
        av: AV,
        el: '#vcomment',
        notify: notify,
        app_id: "3uM9nFQKJdCUOHqwT3LHL5Mt-gzGzoHsz",
        app_key: "3v4CdFJJjh97olrmyHxtdDlt",
        placeholder: "请输入",
        avatar:"mm",
    });
</script>



    





  <section id="comments" class="vcomment">
  </section>

    </div>
    <div class="copyright">
        <p class="footer-entry">©2016-2019 MikiZhu 赣ICP备20004640号</p>
<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>

    </div>
    <div class="full-toc">
        <button class="full"><span class="min "></span></button>
<button class="post-toc-menu"><span class="post-toc-menu-icons"></span></button>
<div class="post-toc"><span class="post-toc-title">目录</span>
    <div class="post-toc-content">

    </div>
</div>
<a class="" id="rocket" ></a>

    </div>
</div>
<div class="acParent"></div>

</body>
<script src="/js/jquery.pjax.js?v=1.0.1" ></script>

<script src="/js/script.js?v=1.0.1" ></script>
<script>
    var img_resize = 'default';
    /*作者、标签的自动补全*/
    $(function () {
        $('.search').AutoComplete({
            'data': ['#机器学习','#算法','#博客搭建','#python','#网站推荐','#考研经验',],
            'itemHeight': 20,
            'width': 418
        }).AutoComplete('show');
    })
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $(".post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        

        /*高亮代码块行号*/
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        
        
    }

    /*打赏页面隐藏与展示*/
    

</script>

<!--加入行号的高亮代码块样式-->

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 542px;
    }
    .nav.fullscreen {
        margin-left: -542px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 492px;
        }
        .nav.fullscreen {
            margin-left: -492px;
        }
        .nav-left {
            width: 100px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 492px;
            margin-left: -492px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
        .nav .hide-list.fullscreen {
            left: 492px
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #e2e0e0;
    }
    
    

    /*列表样式*/
    
    .post .pjax article .article-entry>ol, .post .pjax article .article-entry>ul, .post .pjax article>ol, .post .pjax article>ul{
        border: #e2dede solid 1px;
        border-radius: 10px;
        padding: 10px 32px 10px 56px;
    }
    .post .pjax article .article-entry li>ol, .post .pjax article .article-entry li>ul,.post .pjax article li>ol, .post .pjax article li>ul{
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .post .pjax article .article-entry>ol>li, .post .pjax article .article-entry>ul>li,.post .pjax article>ol>li, .post .pjax article>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    .post .pjax article .article-entry li>ol>li, .post .pjax article .article-entry li>ul>li,.post .pjax article li>ol>li, .post .pjax article li>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    

    /* 背景图样式 */
    
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    
    .nav-right:before {
        content: ' ';
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0.4;
        background: url("http://q8idlsxje.bkt.clouddn.com/%E6%B5%B7%E6%BB%A9.jpg");
        background-repeat: no-repeat;
        background-position: 50% 0;
        -ms-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
    }
    

    
</style>







  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  <script>
    var GUEST_INFO = ['nick','mail','link'];
    var guest_info = 'nick,mail,link'.split(',').filter(function(item){
        return GUEST_INFO.indexOf(item) > -1
    });
    var notify = 'false' == true;
    var verify = 'false' == true;
    new Valine({
      el: '.vcomment',
      notify: notify,
      verify: verify,
      appId: "3uM9nFQKJdCUOHqwT3LHL5Mt-gzGzoHsz",
      appKey: "3v4CdFJJjh97olrmyHxtdDlt",
      placeholder: "请输入",
      pageSize: '10',
      avatar: 'mm',
      lang: 'zh-cn',
      visitor: 'true'
    });
  </script>

</html>
